<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('户列表')" />
    <style type="text/css" rel="styleSheet" >
        div.error{
            color: red;
        }
    </style>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="roomSearParam">
                    <div class="select-list">
                        <ul>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="params[beginCreateDatetime]"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="params[endCreateDatetime]"/>
                            </li>
                            <li class="select-time">
                                <label>更新时间：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="params[beginUpdateDatetime]"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="params[endUpdateDatetime]"/>
                            </li>
                            <li>
                                <label>可居住人数：</label>
                                <input type="text" name="kjzrs"/>
                            </li>
                            <li>
                                <label>实际居住人数：</label>
                                <input type="text" name="jzrs"/>
                            </li>
                            <li>
                                <label>所属场所类型：</label>
                                <select name="sscsLx" th:with="type=${@dict.getType('b_zzslx')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>所属场所名称：</label>
                                <input type="text" placeholder="小区名、酒店名、学校名" name="sscsMc"/>
                            </li>
                            <li>
                                <label>楼号：</label>
                                <input type="text" name="lh"/>
                            </li>
                            <li>
                                <label class="control-label ">所属社区：</label>
                                <input autocomplete="off" class="form-control" type="text" name="sqName" onclick="selectDeptTree()" id="sqName"  >
                                <input type="text" style="display: none;" name="sqCode" id="sqCode" >
                                <script type="text/javascript">
                                    /* 用户管理-修改-选择部门树 */
                                    function selectDeptTree() {
                                        var deptId = $.common.isEmpty($("#sqCode").val()) ? "100" : $("#sqCode").val();
                                        var url = ctx + "system/dept/selectDeptTree/" + deptId;
                                        var options = {
                                            title: '选择社区',
                                            width: "380",
                                            url: url,
                                            callBack: doSubmit
                                        };
                                        $.modal.openOptions(options);
                                    }
                                    function doSubmit(index, layero){
                                        var tree = layero.find("iframe")[0].contentWindow.$._tree;
                                        if ($.tree.notAllowParents(tree)) {
                                            var body = layer.getChildFrame('body', index);
                                            $("#sqCode").val(body.find('#treeId').val());
                                            $("#sqName").val(body.find('#treeName').val());
                                            layer.close(index);
                                        }
                                    }
                                </script>
                            </li>
                            <li>
                                <label>房间号：</label>
                                <input type="text" name="roomCode"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="searchRoom()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="place:room:add">
                    <i class="fa fa-plus"></i> 添加
                </a>-->
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="place:room:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="place:room:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="place:room:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('place:room:edit')}]];
        var removeFlag = [[${@permission.hasPermi('place:room:remove')}]];
        var zzslxDatas = [[${@dict.getType('b_zzslx')}]];
        var prefix = ctx + "place/room";
        $("#roomSearParam").validate({
            focusCleanup: true,
            rules:{
                kjzrs:{
                    digits:true,
                    min:0,
                    max:254
                },
                jzrs:{
                    digits:true,
                    min:0,
                    max:254
                },
                lh:{
                    digits:true,
                    min:0,
                    max:254
                },
                roomCode:{
                    digits:true,
                    min:0,
                    max:65534
                }
            },
            messages:{
                kjzrs:"只能输入0-254之间的正整数",
                jzrs:"只能输入0-254之间的正整数",
                lh:"只能输入0-254之间的正整数",
                roomCode:"只能输入0-65534之间的正整数"
            },
            /*errorPlacement:function(error, element){
                error.appendTo(element.parents("div.form-group").children(".error-mess"));
            },*/
            errorElement:"div"
        });
        function searchRoom(){
            if($.validate.form()){
                $.table.search();
            }
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "户",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'createDatetime',
                    title: '创建时间'
                },
                    {
                        field: 'createBy',
                        title: '创建人'
                    },
                {
                    field: 'updateDatetime',
                    title: '更新时间'
                },
                {
                    field: 'sqName',
                    title: '所属社区'
                },
                {
                    field: 'sscsMc',
                    title: '所属场所名'
                },
                {
                    field: 'sscsLx',
                    title: '所属场所类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(zzslxDatas, value);
                    }
                },
                {
                    field: 'lh',
                    title: '所属楼号'
                },
                {
                    field: 'roomCode',
                    title: '房间号'
                },
                {
                    field: 'kjzrs',
                    title: '可居住人数'
                },
                {
                    field: 'jzrs',
                    title: '实际居住人数'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        /*actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>')*/;
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>